package cn.hfatec.shms.web.yk.ykXmmx.service;

import java.util.List;
import java.util.HashMap;


import cn.hfatec.shms.web.yk.ykHsb.model.YkHsb;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.yk.ykXmmx.model.YkXmmx;
import cn.hfatec.shms.web.yk.ykXmmx.dao.YkXmmxDao;
import cn.hfatec.shms.web.yk.ykXmmx.model.YkXmmxParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("YkXmmxService")
public class YkXmmxService {

    public static final String BEAN_ID = "YkXmmxService";

    //注入Dao层
    @Resource(name = "YkXmmxDao")
    private YkXmmxDao ykXmmxDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param ykXmmxParams
     * @param page
     *
     */
    @Transactional
    public Table queryYkXmmxTable(YkXmmxParams ykXmmxParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", ykXmmxParams);
        return baseDao.queryTableByPage("queryYkXmmx", params, page);
    }
    /**
     * 根据ID获取数据
     *
     * @param hsTime
     * @param hsEnd
     */
    @Transactional
    public List<YkXmmx> getYkXmmxHs(String hsTime,String hsEnd) {

        return ykXmmxDao.getYkXmmxHs(hsTime,hsEnd);
    }

    /**
     *
     * 插入数据
     * @param ykXmmx
     *
     */
    @Transactional
    public void saveYkXmmx(YkXmmx ykXmmx) {
        if(ykXmmx.getId() != null) {
            YkXmmx result = getYkXmmx(ykXmmx.getId());
            if(result != null) {
                ykXmmxDao.update(ykXmmx);
            } else {
                ykXmmxDao.insert(ykXmmx);
            }
        } else {
            ykXmmxDao.insert(ykXmmx);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteYkXmmx(Integer id) {

        ykXmmxDao.delete(id);
    }

    /**
     * 删除数据
     *
     * @param hsTime
     * @param hsEnd
     */
    @Transactional
    public void deleteYkXmmxhs(String hsTime,String hsEnd) {

        ykXmmxDao.deleteHs(hsTime,hsEnd);
    }


    /**
     *
     * 删除数据
     * @param ykXmmxList
     *
     */
    @Transactional
    public void deleteYkXmmxBatch(List<String> ykXmmxList) {
        for(String id : ykXmmxList) {
            deleteYkXmmx(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public YkXmmx getYkXmmx(Integer id) {

        return ykXmmxDao.getYkXmmxById(id);
    }


    /**
     *
     * 根据ID获取数据
     *
     *
     */
    @Transactional
    public YkXmmx getYkXmmxDate() {

        return ykXmmxDao.getYkXmmxByDate();
    }
}